<?php

namespace app\admin\controller;

use app\BaseController;
use think\exception\HttpResponseException;

class AdminBase extends BaseController
{
    public $adminUser = null;

    public function initialize()
    {
        parent::initialize();

        if (empty($this->isLogin())) {
            return $this->redirect(url("login/index"), 302);
        }
    }

    /**
     * 判断是否登陆
     * @return bool
     * User: xyb
     * Date: 2023/3/4 19:45
     */
    public function isLogin() : bool
    {
        $adminUserObj = $this->adminUser = session(config("admin.session_admin"));
        if (empty($adminUserObj)) {
            return false;
        }
        return true;
    }



    public function redirect(...$args)
    {
        throw new HttpResponseException(redirect(...$args));
    }


}